import { notFound } from 'next/navigation';
import { fetchJson } from '@/lib/utils/server';
import { ResultDto } from '@/types/response/common';
import { ChannelDetail } from '@/types/channel';

type Props = {
	params: Promise<{ identifier: string }>;
};

export default async function ChannelIntroPage({ params }: Props)
{
	const { identifier } = await params;
	const res: ResultDto<ChannelDetail> = await fetchJson(`/api/channel/${encodeURIComponent(decodeURIComponent(identifier))}`, {
		method: 'GET'
	});

	if (!res.data) {
		notFound();
	}

	const ch = res.data;

	return (
		<div className="channel-page__tab-content">
			{ch.description ? (
				<p className="channel-page__description">{ch.description}</p>
			) : (
				<p className="channel-page__empty">채널 소개가 없습니다</p>
			)}
		</div>
	);
}